package com.miyake.loveviewweb.client.commonui;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.user.client.ui.ListBox;

public class ComboBoxEx<T> extends ListBox {
    private Map<String, T> map = new HashMap<String, T>();
    
    public void addItem(String item, T object) {
        map.put(item, object);
        super.addItem(item);
    }

    public String getSelectedItemText() {
        return super.getItemText(super.getSelectedIndex());
    }
    
    public T getSelectedObject() {
        try {
            return map.get(this.getSelectedItemText());
        }
        catch (Exception e) {
            return null;
        }
    }
}
